package com.example.composedialogdemo.dialog

import androidx.activity.result.IntentSenderRequest
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog

/**
 * @author: njb
 * @date:   2025/8/16 20:26
 * @desc:   描述
 */
@Composable
fun LoadingDialog(
    showDialog: Boolean,
    onDismissRequest: () -> Unit,
    message : String = "正在加载中..."
){
    if(showDialog){
        Dialog(
            onDismissRequest = onDismissRequest) {
            Surface(
                shape = MaterialTheme.shapes.medium,
                modifier = Modifier
                    .width(200.dp)
                    .height(150.dp),
                color =MaterialTheme.colorScheme.surface
            ){
                Column(
                    modifier = Modifier.padding(16.dp),
                    horizontalAlignment =   Alignment.CenterHorizontally,
                    verticalArrangement = Arrangement.Center
                ){
                    CircularProgressIndicator()
                    Spacer(modifier = Modifier.height(16.dp))
                    Text(text = message)
                }
            }
        }
    }
}